package com.hxd.otc.module.my.presenter;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.module.my.contract.FinacialContract;
import com.hxd.otc.module.my.model.UserModel;
import com.hxd.otc.module.order.bean.FinacialBean;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.BaseObserver;

/**
 * 作  者 :  zjl
 * 时  间 :  2018/6/4 17:02
 * 描  述 :  ${所有订单页面P}
 */
public class FinacialPresenter extends BasePresenter<FinacialContract.View> implements FinacialContract.Presenter {

   UserModel userModel;

    public FinacialPresenter(FinacialContract.View view) {
        super(view);
        userModel = UserModel.getInstance();
    }

    @Override
    public void doLoadData(int pageSize,int currPage) {
        userModel.getFinancialList(new BaseObserver<FinacialBean>() {
            @Override
            public void onNext(String title, FinacialBean bean) {
                doSetAdapter(bean);
            }

            @Override
            public void onError(int errType, String errMessage) {
                mView.onError(errType);
                mView.showToast(errMessage);
                doShowNoMore();
            }

        }, mView.<BaseBean<FinacialBean>>bindAutoDispose(),pageSize,currPage);
    }

    @Override
    public void doShowNoMore() {
        mView.onShowNoMore();
    }

    @Override
    public void doSetAdapter(FinacialBean bean) {
        mView.onSetAdapter(bean);
        mView.onShowNoMore();
    }
}
